package com.sz;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class EmpDao_ZM {
	public List<zhangmu_biao> SelectAllEmp(String sql) throws ClassNotFoundException{
		String sqlStr = sql;
		List<zhangmu_biao> emps = new ArrayList<zhangmu_biao>();
		try {
			ResultSet rs = DBHelper.executeSql(sqlStr, null);
			zhangmu_biao emp;
			while(rs.next()){
				emp = new zhangmu_biao();
				emp.setId(rs.getInt(1));
				emp.setName(rs.getString(2));
				emp.setTypename(rs.getString(3));
				emp.setPrice(rs.getInt(4));
				emp.setSalarytime(rs.getString(5));
				emps.add(emp);
			}
		
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				DBHelper.dbCloseAll();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return emps;
	}
	
	
	public int insertEmp(zhangmu_biao emp,String sql) throws ClassNotFoundException{
		String sqlStr = sql;
		//emp -> Object[]
		
		Object[] prams = new Object[1];
		int count = 0;
		try {
			count = DBHelper.executeUpdate(sqlStr, prams);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				DBHelper.dbCloseAll();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return count;
	}
	
}
